
//
//  UIButtonExtension.swift
//  SinaWeibo
//
//  Created by apple on 15/11/13.
//  Copyright © 2015年 apple. All rights reserved.
//

import UIKit

extension UIButton {
    
    
    convenience init(title: String?,backImage: String?,color: UIColor?,image: String = "", size: CGFloat = 14) {
        
        //调用构造方法 实例化
        self.init()
        
        
        if title != nil {
            
            setTitle(title, forState: .Normal)
        }

        
        if backImage != nil {
            setBackgroundImage(UIImage(named: backImage!), forState: .Normal)
            setBackgroundImage(UIImage(named: backImage! + "_highlighted"), forState: .Highlighted)
        }
        titleLabel?.font = UIFont.systemFontOfSize(size)
        setImage(UIImage(named: image), forState: .Normal)
        
        if color != nil {
            setTitleColor(color, forState: .Normal)
        }
        
    }
    
}